﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EmbeddedSensorCloud.Core.Plugin;
using System.IO;

namespace EmbeddedSensorCloud.UnitTest
{
    [TestClass]
    public class PluginCore_Test
    {
        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void PluginCore_RemovePlugin_Null_Name_Test()
        {
            PluginCore core = new PluginCore();
            bool result = core.RemovePlugin(plugin: null);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException))]
        public void PluginCore_RemovePlugin_Null_Plugin_Test()
        {
            PluginCore core = new PluginCore();
            core.RemovePlugin(pluginName: null);
        }

        [TestMethod]
        public void PluginCore_RemovePlugin_RandomString_Test()
        {
            PluginCore core = new PluginCore();
            bool result = core.RemovePlugin("sdflkjsdlfj");
            Assert.IsFalse(result);
        }

        [TestMethod]
        public void PluginCore_ClearPlugins_Test()
        {
            PluginCore core = new PluginCore();
            int count = core.ClearPlugins();
            Assert.IsTrue(count >= 0);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentException), "Plugin path cannot be null")]
        public void PluginCore_AddPlugin_Null_Path_Test()
        {
            PluginCore core = new PluginCore();
            core.AddPlugin(null);
        }

        [TestMethod]
        [ExpectedException(typeof(FileNotFoundException))]
        public void PluginCore_AddPlugin_Not_Existing_Test()
        {
            PluginCore core = new PluginCore();
            core.AddPlugin("C:\\abc.dll");
        }
    }
}
